// demoStl.cpp
// Program for demonstrating the STL library
// Author:
//      sibuser

#include <iostream>
#include <vector>
#include <set>
#include <deque>
//#include <multiset>
#include <map>
//#include <multimap>
#include <list>
#include <iterator>

#include <boost/foreach.hpp>

void PrintVec(const std::vector<int>& a_Vector) 
{
    
    std::vector<int>::iterator it;
    std::ostream_iterator<int> output(std::cout, " ");
    // std::cout << std::endl;
    std::copy (a_Vector.begin(), a_Vector.end(), output);
}


int main (int argc, const char** argv)
{
    std::vector<int> vec(10, 1);
    std::cout << "Vector vec = ";
    PrintVec(vec);
       
    vec.push_back(3);
    vec.push_back(4);
    vec.push_back(5);
    vec.push_back(99);
    std::cout << "\nAdded 3 4 5 1 to vec = ";
    PrintVec(vec);
    
    std::cout << "\nSize of vec  " << vec.size();
    std::cout << "\nMax size of vec " << vec.max_size();
    std::string status;
    
    status = vec.empty() ? "empty" : "full" ;
    std::cout << "\nFull of not full the vec = " << status;
    
    std::cout << "\nFunction front for vec = " << vec.front();
    std::cout << "\nFunction back for vec = " << vec.back();
    std::cout << "\nFunction at(3) for vec = " << vec.at(3);
    std::cout << "\nBefore pop of vec = ";
    PrintVec(vec);
    vec.pop_back();
    std::cout << "\n After pop of vec = ";
    PrintVec(vec);
    
    std::vector<int> vec_copy(vec);
    std::cout << "\nCopy of vector    = ";
    PrintVec(vec_copy);

    vec_copy.insert(vec_copy.begin(), 45);
    std::cout << "\nAfter insert      = ";
    PrintVec(vec_copy);
    
    std::cout << "\nRevers of vec     =";
    std::vector<int>::reverse_iterator rit;
    
    for (rit = vec_copy.rbegin(); rit < vec_copy.rend(); ++rit){
        std::cout << " " <<  *rit;
    }
    vec_copy.resize(7);
    std::cout << "\nVec_copy after resize(7) = ";
    PrintVec(vec_copy);
    
    std::cout << "\nBefore swap: " <<  "\nvec = ";
    PrintVec(vec);
    std::cout << "\nvec_copy = ";
    PrintVec(vec_copy);
    vec.swap(vec_copy);
    std::cout << "\nAfter swap: " <<  "\nvec = ";
    PrintVec(vec);

    std::cout << "\nvec_copy = ";
    PrintVec(vec_copy);
    std::cout << "\n Erase (3,7) ";

    vec.erase(vec.begin() + 3,vec.begin() + 7);
    std::cout << "\n After erase = ";
    PrintVec(vec);

    vec.clear();
    status =  (vec.empty()) ? "empty" : "full";
    std::cout << "\nVec after clear: " << status;
    std::cout << std::endl;

    // Demo a deque

    std::deque<int> first(10,2);

    BOOST_FOREACH( int& i, first){
        std::cout << first.at(++i) << " ";
    }
    std::cout << std::endl;
    std::deque<int> second(4,55);
    std::deque<int> third(second);
    second.assign(5,20);
    
    
    return 0;
    
}
    
